<?php
/**
 * Created by PhpStorm.
 * User: 盛茂国
 * Tel: 18394333958
 * Date: 2020/6/2
 * Time: 10:31
 */

namespace app\api\controller;


use app\common\controller\Api;
use think\Request;

class Userbill extends Api
{
    protected $noNeedLogin=['catcoin','money'];
    protected $noNeedRight=['catcoin','money'];

    public function catcoin(Request $request){
       if($request->isPost()){
           $opid=$request->param('openid');
           $uid=db('user')->where('open_id','=',$opid)->value('id');
           $pageNum=($request->param('pageNum')) ? $request->param('pageNum') : 5;
           $page=($request->param('page')) ? $request->param('page','intval') :0;
           $data=db('usercatcoinlog')->where('uid','=',$uid)->page($page,$pageNum)->select();
           foreach ($data as $k=>$item){
               $data[$k]['createtime']=date('Y-m-d H:i:s',$item['createtime']);
           }
           return json(['status'=>200,'msg'=>'成功获取用户猫币流水','data'=>$data]);
       }else{
           return json(['status'=>400,'msg'=>'非法请求']);
       }

    }
    public function money(Request $request){
        if($request->isPost()){
            $opid=$request->param('openid');
            $uid=db('user')->where('open_id','=',$opid)->value('id');
            $pageNum=($request->param('pageNum')) ? $request->param('pageNum') : 5;
            $page=($request->param('page')) ? $request->param('page','intval') :0;
            $data=db('usermoneylog')->where('uid','=',$uid)->page($page,$pageNum)->select();

            foreach ($data as $k=>$item){
                $data[$k]['createtime']=date('Y-m-d H:i:s',$item['createtime']);
            }
            return json(['status'=>200,'msg'=>'成功获取用户资金流水','data'=>$data]);
        }else{
            return json(['status'=>400,'msg'=>'非法请求']);
        }
    }
}